package com.goole.shape;

public class Test2 {
    public static void main(String[] args) {
        shapeArea(new Shape[]{new Circle("圆", 5),
                new Rectangle("矩形", 4, 2),
                new Triangle("三角形", 5)});
        System.out.println();
        shapePerimeter(new Shape[]{new Circle("圆", 5),
                new Rectangle("矩形", 4, 2),
                new Triangle("三角形", 5)});

        Shape shape = new Circle("圆", 4);

        if (shape instanceof Triangle) {
            ((Triangle) shape).getPerimeter();
        } else if (shape instanceof Circle) {
            ((Circle) shape).print();
        } else {
            System.out.println("false");
        }
    }

    public static void shapeArea(Shape[] shapes) {
        for (Shape shape : shapes) {
            System.out.println(shape.getName() + " " + shape.getArea());
        }
    }

    public static void shapePerimeter(Shape[] shapes) {
        for (Shape shape : shapes) {
            System.out.println(shape.getName() + " " + shape.getPerimeter());
        }
    }
}
